﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LibNiconico.NiconicoApi.Internal;
using LibNiconico.NiconicoApi.Extentions;
using LibNiconico.NiconicoApi.Lives.WatchPage;

namespace LibNiconico.NiconicoApi.Lives.Comments.PostKey
{
    /// <summary>
    /// ニコニコ生放送ポストキー取得問い合わせ情報
    /// </summary>
    internal sealed class NicoLiveGetPostKeyQueryInfo:NicoUrlAble
    {
        /// <summary>
        /// スレッド番号
        /// </summary>
        internal string Thread { get; set; }
        
        /// <summary>
        /// ブロック番号
        /// </summary>
        public int BlockNo { get; set; }

        /// <summary>
        /// uselc
        /// </summary>
        internal int UseLc { get; set; }

        /// <summary>
        /// langflag
        /// </summary>
        internal int LangFlag { get; set; }

        /// <summary>
        /// ロケールフラグ
        /// </summary>
        internal int LocaleFlag { get; set; }

        /// <summary>
        /// seatフラグ
        /// </summary>
        internal int SeatFlag { get; set; }


        /// <summary>
        /// ユーザID
        /// </summary>
        internal string UserId { get; set; }

        /// <summary>
        /// ニコニコ生放送閲覧履歴
        /// </summary>
        internal NicoLiveHistory History { get; set; }


        internal NicoLiveGetPostKeyQueryInfo(string thread, int blockNo, NicoLiveHistory history, string userId)
            : this(thread, blockNo, history, userId, 1, 1, 1, 1)
        {

        }

        internal NicoLiveGetPostKeyQueryInfo(string thread, int blockNo,NicoLiveHistory history, string userId, int useLc, int langFlag, int localFlag, int seatFlag )
        {
            this.Thread = thread;
            this.BlockNo = blockNo;
            this.UseLc = useLc;
            this.LangFlag = langFlag;
            this.LocaleFlag = localFlag;
            this.SeatFlag = seatFlag;
            History = history;
            UserId = userId;
        }



        /// <summary>
        /// URLパスとして取得
        /// </summary>
        /// <returns></returns>
        internal override string AsPath()
        {
            return "api/getpostkey";
        }

        /// <summary>
        /// URL問い合わせ文字列として取得
        /// </summary>
        /// <returns></returns>
        internal override string AsQuery()
        {
            

            QueryStrings query = new QueryStrings();
            query.Add("thread", Thread.ToString());
            query.Add("block_no", BlockNo.ToString());

            
            query.Add("uselc", UseLc.ToString());
            query.Add("lang_flag", LangFlag.ToString());
            query.Add("locale_flag", LocaleFlag.ToString());
            query.Add("seat_flag", SeatFlag.ToString());
            
            return query.ToString();
        }
    }
}
